package adapter;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import java.util.ArrayList;

/**
 * Created by liuxiaobin on 2016/11/23
 * 导航页的adapter
 */

public class WelComeVPAdapter extends PagerAdapter{
    private ArrayList<View> mPageVList;

    public WelComeVPAdapter(ArrayList<View> pageVList){
        this.mPageVList = pageVList;
    }

    @Override public int getCount() {
        return mPageVList.size();
    }

    @Override public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    // 初始化每个Item
    @Override public Object instantiateItem(View container, int position) {
        ((ViewPager) container).addView(mPageVList.get(position));
        return mPageVList.get(position);
    }

    // 销毁每个Item
    @Override public void destroyItem(View container, int position, Object object) {
        ((ViewPager) container).removeView(mPageVList.get(position));
    }
}
